﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace Lab8_Security
{
    public partial class Member : System.Web.UI.Page
    {
        public string style = "display:none";
        protected void Page_Load(object sender, EventArgs e)
        {
            int IdRole = -1;
            User UserLogin = (User)Session["UserLogin"];
            if (UserLogin == null)
            {
                Message.InnerHtml = Server.HtmlEncode("You do not login, please logging to this page! ");
                return;
            }
            else
            {
                IdRole = UserLogin.IdRole;
                style = "";
                if (IdRole == 1)    // Admin
                {
                    Message.InnerHtml = Server.HtmlDecode("<b><i>You are Admin</i></b>");
                    UserName.Text = UserLogin.Username;
                    if(UserLogin.Birthday!=null)
                        Birthday.Text = UserLogin.Birthday.ToString();
                    if (UserLogin.Email != null)
                        Email.Text = UserLogin.Email;
                    if (UserLogin.Phone != null)
                        Phone.Text = UserLogin.Phone;
                }
                if(IdRole==2)   // Member
                {
                    Message.InnerHtml = Server.HtmlDecode("<b><i>You are Member</i></b>");
                    UserName.Text = UserLogin.Username;
                    if (UserLogin.Birthday != null)
                        Birthday.Text = UserLogin.Birthday.ToString();
                    if (UserLogin.Email != null)
                        Email.Text = UserLogin.Email;
                    if (UserLogin.Phone != null)
                        Phone.Text = UserLogin.Phone;
                }
            }
            
        }
    }
}